package com.ajie.service.impl;

import com.ajie.entity.Record;
import com.ajie.entity.Relation;
import com.ajie.mapper.ChatMapper;
import com.ajie.service.ChatService;
import com.ajie.utils.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
public class ChatServiceImpl implements ChatService {
    
    @Autowired
    private ChatMapper chatMapper;
    
    @Override
    public Result addFriend(Relation relation) {
        log.info("该文件名是：ChatServiceImpl,该方法是：addFriend");
        chatMapper.addFriend(relation);
        return Result.success("申请添加好友成功！");
    }
    
    @Override
    public Result findNewFriend(Long id) {
        log.info("该文件名是：ChatServiceImpl,该方法是：findNewFriend");
        List<Relation> relations = chatMapper.findNewFriend(id);
        return Result.success("查找新朋友成功！",relations);
    }
    
    @Override
    public Result agreeNewFriend(Long id) {
    
        log.info("该文件名是：ChatServiceImpl,该方法是：argeeNewFriend");
        chatMapper.agreeNewFriend(id);
        return Result.success("已同意好友申请");
    }
    
    @Override
    public Result findMyFriend(Long id) {
        log.info("该文件名是：ChatServiceImpl,该方法是：findMyFriend");
        List<Relation> relations = chatMapper.findMyFriend(id);
        return Result.success("获取我的好友列表",relations);
    }
    
    @Override
    public Result addRecord(Record record) {
        log.info("该文件名是：ChatServiceImpl,该方法是：addRecord");
        chatMapper.addRecord(record);
        return Result.success("添加聊天记录成功！");
    }
    
    @Override
    public Result findRecords(Long id) {
        log.info("该文件名是：ChatServiceImpl,该方法是：findRecords");
        List<Record> records = chatMapper.findChatDate(id);
        return Result.success("查找聊天记录成功！",records);
    }
}
